package com.csii.ssm.util;

import com.csii.ssm.virwebservice.SvcServiceStub;
import com.csii.ssm.virwebservice.SvcServiceStub.SvcInfo;
import com.csii.ssm.virwebservice.SvcServiceStub.TransX;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;

/**
 * Created by Charis on 2016/9/5.
 */
public class SvcServiceFactory {

    private static SvcServiceStub svcServiceStub;

    public SvcServiceFactory() {

    }


    public static SvcServiceStub getInstance() throws AxisFault {
        if(svcServiceStub==null){
            svcServiceStub = new SvcServiceStub();
            Options options =svcServiceStub._getServiceClient().getOptions();
            options.setTimeOutInMilliSeconds(90000000);// 设置超时(单位是毫秒)
            //s._getServiceClient().addHeader(createHeaderOMElement());
            svcServiceStub._getServiceClient().setOptions(options);
        }
        return svcServiceStub;
    }

    /**
     * 返回TransX对象
     * @return
     */
    public static TransX getTransX(){
        return new TransX();
    }

    /**
     * 把svcInfo封装到TransX
     * @param svc
     * @return
     */
    public static TransX packageSvcInfoToTransX(SvcInfo svc) {
        TransX t = getTransX();
        t.setIn0(svc);
        return t;
    }
}
